package com.evola.dbsm.view.script.list
{
	import com.evola.dbsm.communication.Commands;
	import com.evola.dbsm.model.ProjectBean;
	import com.evola.dbsm.model.ScriptBean;
	import com.evola.dbsm.service.RemoteServiceFacade;
	import com.evola.dbsm.service.ServiceResult;
	import com.evola.dbsm.utils.MockDataSource;
	import com.evola.dbsm.view.navigation.NavigationPresenter;
	
	import flash.events.MouseEvent;
	
	import mx.collections.IList;

	[Bindable]
	public class ScriptListPresenter
	{

		public var model:ScriptListModel=new ScriptListModel();
		public var view:ScriptListView;

		public function ScriptListPresenter()
		{

		}

		public function init(project : ProjectBean):void
		{

			model.project = project;
			
			RemoteServiceFacade.executeCommand(Commands.LOAD_PROJECT_SCRIPTS_COMMAND, project, function(result:ServiceResult):void
			{

				var scripts:IList=result.data as IList;

				model.scripts=scripts;
			});
		}

		public function selectScript(script : ScriptBean) : void{
			
			Presenters.navigationPresenter.showScript(script);
		}
		
		public function addScript() : void{
			
			Presenters.navigationPresenter.addScript();
		}
		
		public function editProject() : void{
			
			Presenters.navigationPresenter.editProject();
		}

	}
}
